class Solution
{
public:
    int miceAndCheese(vector<int> &reward1, vector<int> &reward2, int k)
    {
        int n = reward1.size();
        vector<int> diff(n);
        for (int i = 0; i < n; ++i)
        {
            diff[i] = reward1[i] - reward2[i];
        }

        int result = accumulate(reward2.begin(), reward2.end(), 0);
        sort(diff.rbegin(), diff.rend());
        result += accumulate(diff.begin(), diff.begin() + k, 0);
        return result;
    }
};